import Vue from "vue";
import VueRouter from "vue-router";
import welcome from "../components/welcome.vue";
import index from "../components/statistics/index/index.vue";
import retail from "../components/statistics/retail/retail.vue";
import Physicalanalysis from "../components/statistics/retail/Physicalanalysis.vue";
import noPhysicalanalysis from "../components/statistics/retail/noPhysicalanalysis.vue";
import Platformanalysis from "../components/statistics/retail/Platformanalysis.vue";
import ecompro from "../components/statistics/ecom/ecompro.vue";
import ecomcapital from "../components/statistics/ecom/ecomcapital.vue";
import maeketcompany from "../components/statistics/market/maeketcompany.vue";
import marketshop from "../components/statistics/market/marketshop.vue";
import platanalyse from "../components/statistics/analyse/platanalyse.vue";
import totalanalyse from "../components/statistics/analyse/totalanalyse.vue";
import admingl from "@/components/admin/admingl";
import adminuser from "@/components/admin/adminuser";
import department from "@/components/admin/department.vue";
import authority from "@/components/admin/authority.vue";
import accountmanagement from "@/components/BusinessManagement/accountmanagement.vue";
import channel from "@/components/BusinessManagement/channel.vue";
import info from "@/components/BusinessManagement/info.vue";
import maintain from "@/components/BusinessManagement/maintain.vue";
import person from "@/components/BusinessManagement/person.vue";
import store from "@/components/BusinessManagement/store.vue";
import datareport from "@/components/datareport/datareport.vue";
import opinfo from "@/components/operationsmanagement/opinfo.vue";
import feedback from "@/components/operationsmanagement/feedback.vue";
import service from "@/components/operationsmanagement/service.vue";
import policy from "@/components/operationsmanagement/policy.vue";
import ModuleIV from "@/components/operationsmanagement/ModuleIV.vue";
import upload from "@/components/upload";
Vue.use(VueRouter);
const routes = [
  { path: "/", redirect: "/login" },
  {
    path: "/login",
    name: "login",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/login.vue"),
  },
  {
    path: "/choose",
    name: "choose",
    component: () =>
      import(
        /* webpackChunkName: "about" */ "../views/statistics/choose/index.vue"
      ),
  },
  {
    path: "/home",
    component: () => import("../views/statistics/home/home.vue"),
    redirect: "/index",
    children: [
      { path: "/opinfo", component: opinfo },
      { path: "/feedback", component: feedback },
      { path: "/service", component: service },
      { path: "/policy", component: policy },
      { path: "/ModuleIV", component: ModuleIV },

      { path: "/datareport", component: datareport },
      { path: "/accountmanagement", component: accountmanagement },
      { path: "/channel", component: channel },
      { path: "/info", component: info },
      { path: "/maintain", component: maintain },
      { path: "/person", component: person },
      { path: "/store", component: store },
      { path: "/welcome", component: welcome },
      { path: "/index", component: index },
      { path: "/adminuser", component: adminuser },
      { path: "/upload", component: upload },

      { path: "/department", component: department },
      { path: "/authority", component: authority },
      { path: "/admingl", component: admingl },
      { path: "/retail", component: retail },
      { path: "/Physicalanalysis", component: Physicalanalysis },
      { path: "/noPhysicalanalysis", component: noPhysicalanalysis },
      { path: "/Platformanalysis", component: Platformanalysis },
      { path: "/ecompro", component: ecompro },
      { path: "/ecomcapital", component: ecomcapital },
      { path: "/maeketcompany", component: maeketcompany },
      { path: "/marketshop", component: marketshop },
      { path: "/platanalyse", component: platanalyse },
      { path: "/totalanalyse", component: totalanalyse },
    ],
  },
];
const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  if (to.path === "/login") return next();
  const tokenStr = window.sessionStorage.getItem("token");
  if (!tokenStr) return next("/login");
  next();
});
export default router;
